const express = require('express')
const app = express()
const port = 8000
const fs = require('fs')
app.get('/getHeroList', (req, res) => {
    res.send(fs.readFileSync('./data/hero.json'))
})
app.get('/getHeroById', (req, res) => {
    const { id } = req.query
    const data = fs.readFileSync('./data/hero.json')
    const list = JSON.parse(data)
    const hero = list.find(item => item.id == id)
    res.send(hero)

})
app.listen(port, () => {
    console.log(`Example app listening at http://localhost:${port}`);
})